<?php

namespace app\api\command;
use app\common\model\Packages;
use fast\Random;
use think\console\Command;
use think\console\Input;
use think\console\Output;

class Kgjtongbuonsale extends Command
{
    protected $model = null;

    protected function configure()
    {
        $this->setName('kgjtongbuonsale')->setHelp('卡管家停售同步下架')->setDescription('卡管家停售同步下架');

    }

    protected function execute(Input $input, Output $output)
    {
        $data['goodsStatus'] = 'on_sale';
        $path = '/api/card/open/getGoodsList';
        $result = kgjcurl($path, $data);
        if($result){
            foreach ($result['data'] as $k => $v) {
                $info = Packages::where(['packages_id' => $v['goodsCode'], 'platform_type' => 6])->find();
                if (!$info) {
                    $info->status = 2;
                    $info->save();
                }else{
                    echo '无商品';
                }
            }
        }
    }
}
